{template 'common/header'}
{php echo $this -> set_tabbar($action, 3);}
{if $operation == 'display'}
<div class="main">
    <style>
        .form-control-excel {
            height: 34px;
            padding: 6px 12px;
            font-size: 14px;
            line-height: 1.42857143;
            color: #555;
            background-color: #fff;
            background-image: none;
            border: 1px solid #ccc;
            border-radius: 4px;
            -webkit-box-shadow: inset 0 1px 1px rgba(0,0,0,.075);
            box-shadow: inset 0 1px 1px rgba(0,0,0,.075);
            -webkit-transition: border-color ease-in-out .15s,-webkit-box-shadow ease-in-out .15s;
            -o-transition: border-color ease-in-out .15s,box-shadow ease-in-out .15s;
            transition: border-color ease-in-out .15s,box-shadow ease-in-out .15s;
        }
    </style>
    <div class="panel panel-info">
        <div class="panel-heading">筛选</div>
        <div class="panel-body">
            <form action="" method="post" class="form-horizontal" role="form">
                <div class="form-group">
                    <label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label">关键字</label>
                    <div class="col-sm-2 col-lg-2">
                        <input type="text" id="keyword" name="keyword" value="{$keyword}" class="form-control-excel" placeholder="请输入关键词" data-rule-required="true">
                    </div>
                    <label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label">类型</label>
                    <div class="col-sm-2 col-lg-3">
                        <select name="type" class="input-small form-control">
                            <option {if $type=='cardnumber' || empty($type)}selected="selected"{/if} value="cardnumber">会员卡号</option>
                            <option {if $type=='username'}selected="selected"{/if} value="username">用户名</option>
                            <option {if $type=='tel'}selected="selected"{/if} value="tel">手机号码</option>
                        </select>
                    </div>
                    <div class="col-sm-3 col-lg-2">
                        <input type="hidden" name="token" value="{$_W['token']}" />
                        <input name="submit" type="submit" class="btn btn-primary" value="查询">
                        <!--<a class="btn btn-primary" href="{php echo create_url('site/module', array('do' => 'CardExcel', 'name' => 'weisrc_icard'))}">导出会员</a>-->
                        <!--<button class="btn btn-default"><i class="fa fa-search"></i> 搜索</button>-->
                    </div>
                </div>
            </form>
        </div>
    </div>
    <form action="" method="post" class="form-horizontal form" >
        <div class="panel panel-default">
            <div class="table-responsive panel-body">
                <table class="table table-hover">
                    <thead class="navbar-inner">
                    <tr>
                        <th style="width:12%;">会员卡号</th>
                        <th style="width:8%;">昵称</th>
                        <th style="width:8%;">用户名称</th>
                        <th style="width:14%;">手机号码</th>
                        <th style="width:10%;">余额</th>
                        <th style="width:8%;">剩余积分</th>
                        <th style="width:8%;">状态</th>
                        <th style="width:10%;">消费/充值</th>
                        <th style="width:22%;">余额/积分/编辑</th>
                    </tr>
                    </thead>
                    <tbody id="level-list">
                    {loop $list $item}
                    <tr>
                        <td>{$item['cardnumber']}</td>
                        <td style="white-space:normal;"><img width="50" style="border-radius: 3px;" src="{$item['headimgurl']}"/></br>{$fans[$item['uid']]['nickname']}</td>
                        <td>{$fans[$item['uid']]['realname']}</td>
                        <td>{$fans[$item['uid']]['mobile']}</td>
                        <td>
                            {$fans[$item['uid']]['credit2']}
                        </td>
                        <td>{php echo intval($fans[$item['uid']]['credit1'])}</td>
                        <td>
                            {if $item['status'] == 0}
                            <span class="label label-success">正常</span>
                            {else}
                            <span class="label label-danger">冻结</span>
                            {/if}
                        </td>
                        <td>
                            <a class="btn btn-default btn-sm" title="消费日志" href="{php echo $this->createWebUrl('ShopingLog', array('cardid' => $item['id']))}"><i class="fa fa-area-chart"></i></a>
                            <a class="btn btn-default btn-sm" title="充值日志" href="{php echo $this->createWebUrl('RechargeLog', array('cardid' => $item['id']))}"><i class="fa fa-bar-chart"></i></a>
                        </td>
                        <td>
                            <a href="javascript:;" title="充值" class="btn btn-default btn-sm pay" data-from_user="{$item['from_user']}"  data-codeid="{$item['id']}" data-status="{$item['status']}" title="充值" ><i class="fa fa-yen"></i></a>
                            <a href="javascript:;" title="积分" class="btn btn-default btn-sm bestow" data-memberid="{$item['id']}" data-status="{$item['status']}" title="赠送积分"><i class="fa fa-money"></i></a>
                            <a class="btn btn-default btn-sm" href="{php echo $this->createWebUrl('card', array('id' => $item['id'], 'op' => 'post'))}"><i class="fa fa-pencil"></i></a>
                            {if $item['status'] == 0}
                            <a class="btn btn-default btn-sm" onclick="return confirm('您确定要冻结吗？');return false;" href="{php echo $this->createWebUrl('checkedCardstatus', array('id' => $item['id'], 'status' => $item['status']))}"
 title="冻结"><i class="fa fa-lock"></i>冻结</a>
                            {else}
                            <a class="btn btn-default btn-sm" onclick="return confirm('您确定要解冻吗？');return false;" href="{php echo $this->createWebUrl('checkedCardstatus', array('id' => $item['id'], 'status' => $item['status']))}"
                                title="解冻"><i class="fa fa-unlock"></i>解冻</a>
                            {/if}
                        </td>
                    </tr>
                    {/loop}
                    </tbody>
                </table>
            </div>
        </div>
    </form>
    {$pager}

    <div id="modal-module-menus-recharge"  class="modal fade" tabindex="-1">
        <div class="modal-dialog" style='width: 520px;'>
            <div class="modal-content">
                <div class="modal-header"><button aria-hidden="true" data-dismiss="modal" class="close" type="button">×</button><h3>会员充值</h3></div>
                <div class="modal-body">
                    <form id="Form1" action="{php echo $this->createWebUrl('addCardPrice')}" method="post" class="form-horizontal">
                        <input type="hidden" name="id" id="id" value="0">
                        <input type="hidden" name="status" id="status" value="0">
                         <input type="hidden" name="from_user" id="from_user" value="0">
                        <div class="form-group">
                            <label class="col-xs-12 col-sm-3 col-md-2 control-label">充值金额</label>
                            <div class="col-sm-9">
                                <div class="input-append">
                                    <input type="text" placeholder="金额" name="price" id="price" class="form-control" data-rule-required="true" data-rule-number="true">
                                    <span class="add-on"><i class="icon-cny"></i></span>
                                </div>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-xs-12 col-sm-3 col-md-2 control-label">操作原因</label>
                            <div class="col-sm-9">
                                <textarea name="remark" id="remark" class="form-control"></textarea>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-xs-12 col-sm-3 col-md-2 control-label"></label>
                            <div class="col-sm-9">
                                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                                <button type="submit" class="btn btn-primary">提交</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
    <div id="modal-module-menus-score"  class="modal fade" tabindex="-1">
        <div class="modal-dialog" style='width: 520px;'>
            <div class="modal-content">
                <div class="modal-header"><button aria-hidden="true" data-dismiss="modal" class="close" type="button">×</button><h3>赠送积分(增减)</h3></div>
                <div class="modal-body">
                    <form id="Form2" action="{php echo $this->createWebUrl('addCardScore')}" method="post"
                          class="form-horizontal  form-modal">
                        <input type="hidden" name="id" id="id2" value="{$item['id']}">
                        <input type="hidden" name="status" id="status2" value="{$item['status']}">
                        <div class="form-group" style="margin-bottom: 0px;">
                            <label class="col-xs-12 col-sm-3 col-md-2 control-label">赠送积分</label>
                            <div class="col-sm-9">
                                <input type="text" placeholder="积分" name="score" id="score" class="form-control"
                                       data-rule-required="true" data-rule-number="true">
                                <span class="help-block" style="padding:0px;color:#f00;">
                                    输入500,表示增加500;<br>输入-500表示减少500;
                                </span>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-xs-12 col-sm-3 col-md-2 control-label">操作原因</label>
                            <div class="col-sm-9">
                                <textarea name="remark" class="form-control"></textarea>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-xs-12 col-sm-3 col-md-2 control-label"></label>
                            <div class="col-sm-9">
                                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                                <button type="submit" class="btn btn-primary">提交</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">
    $(function () {
        $("tr").delegate(".pay", "click", function () {
            $("#price").val("100");
            $("#id").val($(this).attr("data-codeid"));
            $("#status").val($(this).attr("data-status"));
            $("#from_user").val($(this).attr("data-from_user"));
           
            $('#modal-module-menus-recharge').modal();
        });

        $("tr").delegate(".bestow", "click", function () {
            $("#score").val("100");
            $("#id2").val($(this).attr("data-memberid"));
            $("#status2").val($(this).attr("data-status"));
            $('#modal-module-menus-score').modal();
        });
    });
</script>
{elseif $operation == 'post'}
<div class="main">
    <form action="" method="post" onsubmit="return check();" class="form-horizontal form" enctype="multipart/form-data">
        <h4>{$title}</h4>
        <div class="panel panel-default">
            <div class="panel-body">
                <div class="form-group">
                    <div class="col-sm-1" style="width: 100px;">
                        姓名
                    </div>
                    <div class="col-sm-3">
                        <input type="text" name="username" id="username" value="{$user['realname']}" class="form-control" />
                    </div>
                    <div class="col-sm-1" style="width: 100px;">
                        会员等级
                    </div>
                    <div class="col-sm-3">
                        <input type="text" name="level" id="level" value="{$level['levelname']}" class="form-control" disabled="disabled"/>
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-sm-1" style="width: 100px;">
                        编号
                    </div>
                    <div class="col-sm-3">
                        会员号:{$reply['cardnumber']}<br/>微信号:{$reply['from_user']}
                    </div>
                    <div class="col-sm-1" style="width: 100px;">
                        电话
                    </div>
                    <div class="col-sm-3">
                        <input type="text" name="tel" id="tel" value="{$user['mobile']}" class="form-control" />
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-sm-1" style="width: 100px;">
                        剩余金额
                    </div>
                    <div class="col-sm-3">
                        <input type="text" name="coin" id="coin" value="{$user['credit2']}" class="form-control" disabled="disabled"/>
                    </div>
                    <div class="col-sm-1" style="width: 100px;">
                        地址
                    </div>
                    <div class="col-sm-3">
                        <input type="text" name="address" id="address" value="{$user['address']}" class="form-control" />
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-sm-1" style="width: 100px;">
                        剩余积分
                    </div>
                    <div class="col-sm-3">
                        <input type="text" name="balance_score" id="balance_score" value="{$user['credit1']}" class="form-control" disabled="disabled"/>
                    </div>
                    <div class="col-sm-1" style="width: 100px;">
                        性别
                    </div>
                    <div class="col-sm-3">
                        <select name="sex" class="dropdown-select form-control" id="sex">
                            <option class="dropdown-option">请选择你的性别</option>
                            <option value="1">男</option>
                            <option value="0">女</option>
                        </select>
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-sm-1" style="width: 100px;">
                        总积分
                    </div>
                    <div class="col-sm-3">
                        <input type="text" name="balance_score" id="total_score" value="{$reply['total_score']}" class="form-control" disabled="disabled"/>
                    </div>
                    <div class="col-sm-1" style="width: 100px;">
                        生日
                    </div>
                    <div class="col-sm-3">
                        <div class="input-prepend">
                            <span class="add-on"><i class="icon-calendar"></i></span>
                            <input class="input-medium form_datetime valid form-control" value="{php echo date('Y-m-d H:i:s',$user['birthday'])}" readonly="" name="birthday" id="birthday" type="text" data-rule-required="true">
                        </div>
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-sm-1" style="width: 100px;">
                        签到积分
                    </div>
                    <div class="col-sm-3">
                        <input type="text" name="sign_score" id="sign_score" value="{$reply['sign_score']}" class="form-control" disabled="disabled"/>
                    </div>
                    <div class="col-sm-1" style="width: 100px;">
                        领卡时间
                    </div>
                    <div class="col-sm-3">
                        {php echo date('Y-m-d H:i:s', $reply['dateline']);}
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-sm-1" style="width: 100px;">
                        消费奖励积分
                    </div>
                    <div class="col-sm-3">
                        <input type="text" name="spend_score" id="spend_score" value="{$reply['spend_score']}" class="form-control" disabled="disabled"/>
                    </div>
                    <div class="col-sm-1" style="width: 100px;">
                        车牌
                    </div>
                    <div class="col-sm-3">
                        <input type="text" name="carnumber" id="carnumber" value="{$reply['carnumber']}" class="form-control" />
                    </div>
                </div>

                <div class="form-group">
                    <div class="col-sm-1" style="width: 100px;">
                        总消费金额
                    </div>
                    <div class="col-sm-3">
                        <input type="text" name="money" id="money" value="{$reply['money']}" class="form-control" disabled="disabled"/>
                    </div>
                    <div class="col-sm-1" style="width: 100px;"></div>
                    <div class="col-sm-3"></div>
                </div>
            </div>
        </div>
        <div class="form-group">
            <div class="col-sm-12">
                <button type="submit" class="btn btn-primary col-lg-1" name="submit" value="提交">提交</button>
                <input type="hidden" name="token" value="{$_W['token']}" />
            </div>
        </div>
    </form>
</div>
<script type="text/javascript">
    function check() {
        if($.trim($('#username').val()) == '') {
            message('没有输入姓名.', '', 'error');
            return false;
        }s
        return true;
    }
</script>
<link rel="stylesheet" type="text/css" href="../addons/weisrc_icard/template/css/bootstrap-datetimepicker.min.css" media="all">
<script type="text/javascript" src="../addons/weisrc_icard/template/js/bootstrap-datetimepicker.js"></script>
<script type="text/javascript" src="../addons/weisrc_icard/template/js/bootstrap-datetimepicker.zh-CN.js"></script>

<script type="text/javascript">
    $('.form_datetime').datetimepicker({
        language:  'zh-CN',
        weekStart: 1,
        todayBtn:  1,
        autoclose: 1,
        todayHighlight: 1,
        startView: 2,
        forceParse: 0,
        showMeridian: 1
    });
</script>
<script type="text/javascript">
    $(document).ready(function () {
        $('#sex').val("{$user['gender']}");
    });
</script>
{/if}
{template 'common/footer'}
